﻿<UserControl x:Class="PokemonBattleOnline.PBO.Lobby.LobbyView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:ui="clr-namespace:PokemonBattleOnline.PBO.Elements"
             xmlns:l="clr-namespace:PokemonBattleOnline.PBO.Lobby"
             MinHeight="300" MinWidth="280" SizeChanged="UserControl_SizeChanged">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="2*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid x:Name="upper">
            <TabControl Background="{x:Null}" BorderBrush="#80ffffff" BorderThickness="0,1" Padding="0">
                <TabItem Header="房间" Background="{x:Null}">
                    <ScrollViewer Padding="3">
                        <Grid>
                            <ItemsControl Name="Rooms" ItemsPanel="{x:Static ui:Controls.WrapPanel}">
                                <ItemsControl.ItemContainerStyle>
                                    <Style TargetType="ContentPresenter">
                                        <Setter Property="Width" Value="256"/>
                                        <Setter Property="Margin" Value="0,2"/>
                                        <Setter Property="ContentTemplate">
                                            <Setter.Value>
                                                <DataTemplate>
                                                    <l:RoomView x:Name="rv" DataContext="{Binding}"/>
                                                    <DataTemplate.Triggers>
                                                        <DataTrigger Binding="{Binding}" Value="{x:Null}">
                                                            <Setter TargetName="rv" Property="Visibility" Value="Hidden"/>
                                                        </DataTrigger>
                                                    </DataTemplate.Triggers>
                                                </DataTemplate>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                                </ItemsControl.ItemContainerStyle>
                            </ItemsControl>
                            <Grid VerticalAlignment="Top" HorizontalAlignment="Left" Height="32" Width="256">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition/>
                                </Grid.ColumnDefinitions>
                                <Grid Background="Transparent" Opacity="0.5" Grid.ColumnSpan="2">
                                    <Rectangle IsHitTestVisible="False" StrokeThickness="2" Stroke="#80f0ffff"/>
                                    <Ellipse IsHitTestVisible="False" Height="10" Width="10" Stroke="#80f0ffff" StrokeThickness="2"/>
                                    <Ellipse IsHitTestVisible="False" Height="20" Width="20" Stroke="#80f0ffff" StrokeThickness="2"/>
                                    <Line IsHitTestVisible="False" Y2="11" StrokeThickness="2" Stroke="#80f0ffff" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="1,0,0,0"/>
                                    <Line IsHitTestVisible="False" Y2="11" StrokeThickness="2" Stroke="#80f0ffff" HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="1,0,0,0"/>
                                </Grid>
                                <Button Content="单打" x:Name="s" Click="SingleBattle_Click" Cursor="Hand">
                                    <Button.Template>
                                        <ControlTemplate TargetType="Button">
                                            <Grid x:Name="grid" Background="Transparent">
                                                <TextBlock Text="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}" IsHitTestVisible="False" VerticalAlignment="Center" HorizontalAlignment="Center"/>
                                            </Grid>
                                            <ControlTemplate.Triggers>
                                                <Trigger Property="IsMouseOver" Value="True">
                                                    <Setter TargetName="grid" Property="Background" Value="#40ffffff"/>
                                                </Trigger>
                                                <Trigger Property="IsPressed" Value="True">
                                                    <Setter TargetName="grid" Property="Background" Value="#80ffffff"/>
                                                </Trigger>
                                            </ControlTemplate.Triggers>
                                        </ControlTemplate>
                                    </Button.Template>
                                </Button>
                                <Button Content="合作" Click="MultiBattle_Click" Template="{Binding Template,ElementName=s}" Cursor="Hand" Foreground="#336699" Grid.Column="1"/>
                            </Grid>
                        </Grid>
                    </ScrollViewer>
                </TabItem>
                <TabItem Header="用户" Background="{x:Null}">
                    <ScrollViewer Padding="3">
                        <ItemsControl Name="Users" ItemsPanel="{x:Static ui:Controls.WrapPanel}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <ContentControl Content="{Binding}" ContentTemplate="{x:Static ui:Cartes.User}">
                                        <ContentControl.ContextMenu>
                                            <ContextMenu>
                                                <MenuItem Header="聊天" Command="{x:Static l:Chat.NewChatCommand}" CommandParameter="{Binding}"/>
                                            </ContextMenu>
                                        </ContentControl.ContextMenu>
                                    </ContentControl>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                </TabItem>
            </TabControl>
            <Button Content="登出服务器" Click="Exit_Click" Style="{x:Static ui:Controls.XButton}" FontSize="12" Foreground="#336699" Background="#000000" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="2"/>
        </Grid>
        <l:Chat x:Name="chat"/>
        <GridSplitter x:Name="split" Background="Transparent" ShowsPreview="True">
            <GridSplitter.Style>
                <Style TargetType="GridSplitter">
                    <Style.Triggers>
                        <Trigger Property="HorizontalAlignment" Value="Stretch">
                            <Setter Property="Height" Value="3"/>
                        </Trigger>
                        <Trigger Property="VerticalAlignment" Value="Stretch">
                            <Setter Property="Width" Value="3"/>
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </GridSplitter.Style>
        </GridSplitter>
    </Grid>
</UserControl>
